//package com.cqie.filter;
//
//import com.cqie.util.RedisUtils;
//import jakarta.annotation.Resource;
//import jakarta.servlet.*;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//
//
//
//import java.io.IOException;
//import java.util.concurrent.TimeUnit;
//
//public class AccessFilter implements Filter {
//    Logger logger = LoggerFactory.getLogger(AccessFilter.class);
//
//
//    @Resource
//    private RedisUtils redisUtils;
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        //登录接口跳过验证
//        if (request.getRequestURI().contains("/tokenLogin")) {
//            filterChain.doFilter(request, response);
//            return;
//        }
//
//        /** token+redis验证 */
//        String token = request.getHeader("token");
//        if (!redisUtils.hasKey(token)) {
//            logger.info("token过期，请重新登录");
//            return;
//        }
//        //刷新token有效期
//        redisUtils.expire(token, 1, TimeUnit.HOURS);
//        filterChain.doFilter(request, response);
//    }
//
//    @Override
//    public void destroy() {
//    }
//}